﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="SelectCategory.aspx.cs"
    Inherits="ZLCMS.Web.SystemManage.Basics.ProductCategory.SelectCategory" %>

<div class="pageContent">
    <div class="unitBox">
        <div class="pageContent" style="border: 1px #B8D0D6 solid;"><br />
        <h2 class="contentTitle" style="font-size: 20px;">请先选择需要添加产品的分类</h2>
            <div class="pageFormContent" layouth="72">
                <ul class="ztree" id="productcategroy_tree" setting='
{
	view: {
		selectedMulti: false
	},
    data: {
		key: {
			name: "CategoryName"
		},
		simpleData: {
			enable: true,
			idKey: "Id",
			pIdKey: "ParentId"
		},
		keep: {
			parent: false,
			leaf: false
		}
	},
	async: {
		enable: true,
		type: "post",
		url: "/SystemManage/Basics/ProductCategory/CategoryInterface.aspx?opt=load_data",
        otherParam: ["temp", new Date().valueOf()]
	},
    edit: {
		enable: false,
		editNameSelectAll: false,
		showRemoveBtn: true,
		showRenameBtn: false,
		removeTitle: "删除",
		renameTitle: "修改"
	},
	callback: {
		beforeDrag: function (treeId, treeNodes) {
			return false;
		},
        onAsyncSuccess:function(event, treeId, treeNode, msg){
            $.fn.zTree.getZTreeObj(treeId).expandAll(true);
        },
        beforeRename: function(treeId, treeNode, newName, isCancel){
            
            $.get("/SystemManage/Basics/ProductCategory/CategoryInterface.aspx", {opt:"update", CategoryName:newName, ParentId:treeNode.ParentId, Id:treeNode.Id, temp:new Date().valueOf()}, function(data){
                var obj=$.parseJSON(data);
                treeNode.ItemText = obj.ItemText;
                $.fn.zTree.getZTreeObj(treeId).updateNode(treeNode);
                alertMsg.correct("操作成功");
            });
            return true;
        },
        beforeRemove:function(treeId, treeNode){
            alertMsg.confirm("请确认删除当前分类项", {
                okCall: function() {
                    $.get("/SystemManage/Basics/ProductCategory/CategoryInterface.aspx", {opt:"remove", Id:treeNode.Id, temp:new Date().valueOf()}, function(data){
                        $.fn.zTree.getZTreeObj(treeId).removeChildNodes(treeNode);
                        $.fn.zTree.getZTreeObj(treeId).removeNode(treeNode);
                        alertMsg.correct("操作成功");
                    }); 
                }
            });
            return false;
        },
        onClick:function(event, treeId, treeNode, clickFlag){
                if(treeNode.children && treeNode.children.length > 0 )
                    return;
                   <% if(Request["kind"]=="normal_product"){ %>
                      navTab.reload("/SystemManage/Basics/shop/product/Productdetail.aspx?kind=<%=Request["kind"] %>cid=" + treeNode.Id);
               <%}else{ %>
                  navTab.reload("/SystemManage/Basics/ProductSKU/ProductAdd.aspx?cid=" + treeNode.Id);
               <%} %>
        }
	}
}
' />
            </div>
            <script type="text/javascript">
                function addHoverDom(treeId, treeNode) {
                    navTab.reload("/SystemManage/Basics/ProductSKU/ProductAdd.aspx?cid=" + treeNode.Id);
                };
            </script>
        </div>
    </div>
</div>
